package com.java.controller;

import com.java.mapper.UserMapper;
import com.java.model.User;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
public class UserController {
	private final Logger logger = LoggerFactory.getLogger(getClass());
	@Autowired
	private	UserMapper userMapper;
	
	//http://localhost:8088/user/p

	/**
	 * method 可以不设置
	 * @param name
	 * @return
	 */
	@RequestMapping(value = "/user/{name}",method = RequestMethod.GET)
	@ResponseBody
	public String user(@PathVariable("name") String name){
		User findUserByName = userMapper.findUserByName(name);
	return findUserByName.getName()+"-----"+findUserByName.getAge();
	}	

	//http://localhost:8088/test/query?name=l
	@RequestMapping(value = "/test/query")
	@ResponseBody
	public String queryUser(@RequestParam("name") String name){
		System.out.println(name);
		User findUserByName = userMapper.findUserByName(name);
	return findUserByName.getName()+"-----"+findUserByName.getAge();
	}	

}
